using System;
using CosyTrade.Core;
using CosyTrade.Organization;

namespace CosyTrade
{
    [Addin("PayrollFunctionFactory")]
    public class PayrollFunctionFactory:AddinBase,IPayrollFunctionFactory
    {
        #region Implementation of IPayrollFunctionFactory

        public IPayrollFunction BuildPayrollFunction(EmployeeType employeeType)
        {
            IPayrollFunction reVal = null;
            switch (employeeType)
            {
                case EmployeeType.Driver:
                case EmployeeType.SystemManager:
                case EmployeeType.Chinese:
                    reVal = (IPayrollFunction) CurrentAddinManager.GetAddin("NormalPayrollFunction");
                    break;
                case EmployeeType.Manager:
                    reVal = (IPayrollFunction)CurrentAddinManager.GetAddin("ManagerPayrollFunction");
                    break;
                case EmployeeType.Seller:
                    reVal = (IPayrollFunction)CurrentAddinManager.GetAddin("SalePayrollFunction");
                    break;
                default:
                    throw new ArgumentOutOfRangeException("employeeType");
            }
            return reVal;
        }

        #endregion
    }
}